/*MyPhotoIndex Free Photo Organizer <www.myphotoindex.com>
  Copyright (C) <2006-2009>  <Asaf Yarkoni asaf@yarkoni.net>

  This program is free software: you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program.  If not, see <http://www.gnu.org/licenses/>.*/
using System;
using System.Collections.Generic;
using System.Text;
using MyPhotoIndex.Interfaces;
using MyPhotoIndex.Plugins.ImageFormatProviders;
using System.Drawing;
using System.IO;
using MyPhotoIndex.Interfaces.Imaging;
using MyPhotoIndex.Interfaces.ImageFormatProviders;

namespace MyPhotoIndex.Importer
{
    class ImportImageData : IImageData
    {
        private int m_id;
        private string m_fileName;
        private IImageFormatProvider m_formatProvider;
        private DateTime m_dateTaken;
        private Image m_thumbnail;
        private Size m_thumbnailSize = new Size();
        private Object m_syncLock = new object();

        #region IImageData Members

        public event EventHandler ImageDataChangedEvent;

        public void InvokeChangedEvent()
        {
            if (ImageDataChangedEvent != null)
            {
                ImageDataChangedEvent.Invoke(this, EventArgs.Empty);
            }
        }

        public int Id
        {
            get
            {
                return m_id;
            }
            set
            {
                m_id = value;
            }
        }

        public string ImportBatchNumber
        {
            get
            {
                throw new Exception("The method or operation is not implemented.");
            }
            set
            {
                throw new Exception("The method or operation is not implemented.");
            }
        }

        public DateTime DateTaken
        {
            get
            {
                return m_dateTaken;
            }
            set
            {
                m_dateTaken = value;
            }
        }

        public DateTime DateDigitized
        {
            get
            {
                throw new Exception("The method or operation is not implemented.");
            }
            set
            {
                throw new Exception("The method or operation is not implemented.");
            }
        }

        public System.Drawing.Image Thumbnail
        {
            get
            {
                return m_thumbnail;
            }
            set
            {
                lock (m_syncLock)
                {
                    if (m_thumbnail != null)
                    {
                        m_thumbnail.Dispose();
                    }

                    m_thumbnail = value;
                    if (m_thumbnail != null)
                    {
                        m_thumbnailSize = m_thumbnail.Size;
                    }
                    else
                    {
                        m_thumbnailSize = Size.Empty;
                    }
                }
            }
        }

        public int ThumbnailReferences
        {
            get
            {
                return 0;
            }
            set
            {

            }
        }

        public string FileName
        {
            get
            {
                return m_fileName;
            }
            set
            {
                m_fileName = value;
                string extention = Path.GetExtension(m_fileName);
                if (string.IsNullOrEmpty(extention) == false)
                {
                    extention = extention.Remove(0, 1);
                    if (string.IsNullOrEmpty(extention) == false)
                    {
                        m_formatProvider = ImageFormatProviders.Default[extention];
                    }
                }
            }
        }

        public string FileExtention
        {
            get { throw new Exception("The method or operation is not implemented."); }
        }

        public IImageFormatProvider FormatProvider
        {
            get { return m_formatProvider; ; }
        }

        public System.Drawing.Size ImageSize
        {
            get
            {
                return m_thumbnailSize;
            }
            set
            {
                throw new Exception("The method or operation is not implemented.");
            }
        }

        public System.Drawing.Size ThumbnailSize
        {
            get
            {
                return ImageSize;
            }
            set
            {
                throw new Exception("The method or operation is not implemented.");
            }
        }

        public ImageLinkStatus LinkStatus
        {
            get
            {
                return ImageLinkStatus.Valid;
            }
            set
            {
                throw new Exception("The method or operation is not implemented.");
            }
        }

        public string Comment
        {
            get
            {
                throw new Exception("The method or operation is not implemented.");
            }
            set
            {
                throw new Exception("The method or operation is not implemented.");
            }
        }

        public int[] Tags
        {
            get { throw new Exception("The method or operation is not implemented."); }
        }

        public void AddTags(int[] tagIds)
        {
            throw new Exception("The method or operation is not implemented.");
        }

        public void RemoveTag(int tagId)
        {
            throw new Exception("The method or operation is not implemented.");
        }

        public void ClearTags()
        {
            throw new Exception("The method or operation is not implemented.");
        }

        public bool TagExists(int tagId)
        {
            throw new Exception("The method or operation is not implemented.");
        }

        public int Rating
        {
            get
            {
                throw new Exception("The method or operation is not implemented.");
            }
            set
            {
                throw new Exception("The method or operation is not implemented.");
            }
        }

        public bool IsVideo
        {
            get
            {
                throw new Exception("The method or operation is not implemented.");
            }
        }

        public bool CanRotate
        {
            get
            {
                throw new Exception("The method or operation is not implemented.");
            }
        }

        public void Rotate(System.Drawing.RotateFlipType rotationType)
        {
            throw new Exception("The method or operation is not implemented.");
        }

        public void Delete(bool deleteFromDisk, bool sendToRecycleBin)
        {
            throw new Exception("The method or operation is not implemented.");
        }

        public void Update(bool updateExif, bool updateThumbnail)
        {
            throw new Exception("The method or operation is not implemented.");
        }

        public void LoadImage(System.Drawing.Size requestedSize, ImageLoadDelegate imageLoadDelegate)
        {

        }

        public System.Drawing.Image CreateThumbnail(Size size)
        {
            throw new Exception("The method or operation is not implemented.");
        }

        public bool Encrypted
        {
            get { return false; }
        }

        public int[] Categories
        {
            get
            {
                throw new Exception("The method or operation is not implemented.");
            }
        }

        public void AddCategories(int[] categoryIds)
        {
            throw new Exception("The method or operation is not implemented.");
        }

        public void RemoveCategory(int categoryId)
        {
            throw new Exception("The method or operation is not implemented.");
        }

        public void ClearCategories()
        {
            throw new Exception("The method or operation is not implemented.");
        }

        public bool CategoryExists(int tagId)
        {
            throw new Exception("The method or operation is not implemented.");
        }

        public object SyncLock
        {
            get { return m_syncLock; }
        }

        #endregion

        #region IDisposable Members

        public void Dispose()
        {
            if (m_thumbnail != null)
            {
                m_thumbnail.Dispose();
            }
        }

        #endregion

        #region IImageData Members


        public string CameraMaker
        {
            get { throw new Exception("The method or operation is not implemented."); }
        }

        public string CameraModel
        {
            get { throw new Exception("The method or operation is not implemented."); }
        }

        public ImageResolutionUnit ResolutionUnit
        {
            get { throw new Exception("The method or operation is not implemented."); }
        }

        public string SoftwareUsed
        {
            get { throw new Exception("The method or operation is not implemented."); }
        }

        public float Aperture
        {
            get { throw new Exception("The method or operation is not implemented."); }
        }

        public String ExposureTime
        {
            get { throw new Exception("The method or operation is not implemented."); }
        }

        public DateTime LastModifiedDateTime
        {
            get { throw new Exception("The method or operation is not implemented."); }
        }

        public float MaxAperture
        {
            get { throw new Exception("The method or operation is not implemented."); }
        }

        public CameraExposureProgram ExposureProgram
        {
            get { throw new Exception("The method or operation is not implemented."); }
        }

        public int IsoSpeed
        {
            get { throw new Exception("The method or operation is not implemented."); }
        }

        public int ExposureCompensation
        {
            get { throw new Exception("The method or operation is not implemented."); }
        }

        public CameraMeteringMode MeteringMode
        {
            get { throw new Exception("The method or operation is not implemented."); }
        }

        public ImageLightSource LightSource
        {
            get { throw new Exception("The method or operation is not implemented."); }
        }

        public CameraFlashStatus FlashStatus
        {
            get { throw new Exception("The method or operation is not implemented."); }
        }

        public float FocalLength
        {
            get { throw new Exception("The method or operation is not implemented."); }
        }

        #endregion

        #region IImageData Members

        public string FileSignature
        {
            get
            {
                throw new Exception("The method or operation is not implemented.");
            }
            set
            {
                throw new Exception("The method or operation is not implemented.");
            }
        }

        public DateTime LastModified
        {
            get
            {
                throw new Exception("The method or operation is not implemented.");
            }
            set
            {
                throw new Exception("The method or operation is not implemented.");
            }
        }

        #endregion

        #region IImageData Members

        public int VersionParentId
        {
            get { throw new NotImplementedException(); }
            set { throw new NotImplementedException(); }
        }

        public DateTime VersionDate
        {
            get { throw new NotImplementedException(); }
            set { throw new NotImplementedException(); }
        }

        public int VersionsCount
        {
            get { return -1; }
            set { throw new NotImplementedException(); }
        }

        public string SourceLabel
        {
            get { throw new NotImplementedException(); }
            set { throw new NotImplementedException(); }
        }

        #endregion

        #region IDisposable Members

        void IDisposable.Dispose()
        {
            if (m_thumbnail != null)
            {
                m_thumbnail.Dispose();
            }
        }

        #endregion
    }
}
